package abmb.pages;


import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import abmb.utils.PageLinks;
import abmb.utils.PageParts;
import abmb.utils.Utilities;

/**
 * Servlet implementation class Signup
 * @author Andrea Balboni
 * @version 1.0
 */
public class Signup extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Signup() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Utilities utils=new abmb.utils.Utilities();
		PageParts pp=new abmb.utils.PageParts();
		HttpSession session=request.getSession(true);
		response.setContentType("text/html");
		PrintWriter p= response.getWriter();
		p.println(pp.printHTMLHeader("AB-Microblog Signup",utils.isLoggedIn(session)));
		p.println("<section>");
		p.println("<h1>Registrazione:</h1>");
		p.println("<form id=\"signup\" action=\""+PageLinks.getSubscribeLink()+"\" method=\"POST\">");
		p.println("<fieldset>");
			p.println("<legend>Your Details</legend>");
			p.println("<label for=name>Name</label>"); 
			p.println("<input id=name name=name type=text placeholder=\"First Name\" required autofocus autocomplete=\"on\">");
			p.println("<br>");
			p.println("<label for=lastname>Last Name</label>");
			p.println("<input id=lastname name=lastname type=text placeholder=\"Last Name\" required autocomplete=\"on\">");
		p.println("</fieldset>");
		p.println("<fieldset>");
			p.println("<legend>Subscribe</legend>");
			p.println("<label for=nickname>Username</label>");
			p.println("<input id=nickname name=nickname type=text placeholder=\"Choose Username\" required>");
			p.println("<br>");
			p.println("<label for=passwd>Password</label>");
			p.println("<input id=passwd name=passwd type=password placeholder=\"Choose Password\" required>");
		p.println("</fieldset>");
		p.println("<fieldset>");
			p.println("<input type=\"submit\" value=\"Subscribe\">");
			p.println("<input type=\"reset\" value=\"Reset\">");
		p.println("</fieldset>");
		p.println("</form>");
		p.println("</section>");
		p.println(pp.printFooterSection());
		p.println(pp.printHTMLFooter());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
